<template>
	<tm-app ref="app">
		<tm-navbar title="榜样的力量" color="orange" linear="right" linearDeep="accent"></tm-navbar>
		<tm-sheet _class="flex-col">
			<view :key="index" v-for="(item,index) in newslist">
			<tm-text :font-size="30" _class="font-weight-b" @click="loadNewsDetail(item.id)" :label="item.title"></tm-text>
			<tm-divider></tm-divider>
			</view>
		</tm-sheet>
		
		
		<tm-tabbar :autoSelect="false" v-model:active="acc">
			<tm-tabbar-item @click="acc=0" activeColor="orange" url='/pages/index/index' open-type='reLaunch' text="首页"
				icon='tmicon-md-home'></tm-tabbar-item>
			<tm-tabbar-item @click="acc=1" activeColor="orange" url='/pages/index/seach' text="预约"
				icon='tmicon-ios-bookmarks'></tm-tabbar-item>
			<tm-tabbar-item @click="acc=2" activeColor="orange" url='/pages/index/order' text="订单"
				unicon="tmicon-ios-filing" icon="tmicon-ios-filing"></tm-tabbar-item>
			<tm-tabbar-item @click="acc=3" activeColor="orange" url='/pages/index/my' text="我" unicon="tmicon-account"
				icon="tmicon-userplus-fill"></tm-tabbar-item>
		</tm-tabbar>
		
	</tm-app>
</template>

<script lang="ts" setup>
	import { ref } from "vue"
	import { onLoad } from "@dcloudio/uni-app"
	import { pagesNews } from "@/api/news"

	const newslist = ref([]);
	const id = ref("");
	onLoad((e) => {
		
		loadNewDetail();
	})
	
	const loadNewDetail = async() => {
		let param = {"id":id.value};
		const result = await pagesNews(param);

		newslist.value = result;
	}
	
	function loadNewsDetail(ids : string){
		console.log(ids);
		uni.redirectTo({
			url: `/pages/news/read?id=${ids}`
		})
	}
</script>